package com.yanqu.road.server.cmd.cross.group;

import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cross.group.CrossGroupProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.systemgroup.CrossSystemGroupMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.S_CROSS_SYSTEM_GROUP_CHAT_LIST, desc = "系统跨服分组聊天列表(美女走镖等）")
public class SystemCrossGroupChatListCmd extends AbstractCommand {

    private int groupId;
    int systemId;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossGroupProto.SystemCrossGroupChatListReqMsg reqMsg = CrossGroupProto.SystemCrossGroupChatListReqMsg.parseFrom(packet.getBytes());
        groupId = reqMsg.getGroupId();
        systemId = reqMsg.getSystemId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        CrossGroupProto.SystemCrossGroupChatListReqMsg.Builder reqMsg = CrossGroupProto.SystemCrossGroupChatListReqMsg.newBuilder();
        reqMsg.setGroupId(groupId);
        reqMsg.setSystemId(systemId);
        if(systemId == eSystemId.NewMonopolyMarket.getValue()){
            CrossSystemGroupMgr.sendAppointActivityPacket(player.getUserId(), Protocol.C2_SYSTEM_GROUP_CHAT_LIST, systemId, reqMsg);
        }else {
            YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.C_SYSTEM_GROUP_CHAT_LIST, reqMsg);
            GamePlayerMgr.sendPacket(player.getUserId(), pbMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
